package com.jeasonzhao.commons.xml;

import com.jeasonzhao.commons.utils.Algorithms;

public class XMLAttribute implements java.io.Serializable
{
    private static final long serialVersionUID = 1L;
    private String name = null;
    private String value = null;
    public XMLAttribute()
    {
    }

    public XMLAttribute(String strName,Object value)
    {
        this.name = strName;
        setValue(value);
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public void setValue(Object value)
    {
        this.value = value == null ? null : Algorithms.toString(value);
    }

    public String getName()
    {
        return name;
    }

    public String getValue()
    {
        return value;
    }

    public boolean isNamed(String ...names)
    {
        if(null == names)
        {
            return false;
        }
        for(String s : names)
        {
            if(s == null)
            {
                continue;
            }
            if(s.equalsIgnoreCase(this.getName()))
            {
                return true;
            }
        }
        return false;
    }
}
